import java.util.*;

import java.io.*;

public class Practice2 {
    /*
    链接https://www.nowcoder.com/practice/a5a0b05f0505406ca837a3a76a5419b3?tpId=230&tqId=40416&ru=/exam/oj
    利用二维前缀和来做, 可以用快读模板优化差不多40ms


     */
    public static Read in = new Read();
    public static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    public static void main(String[] args) throws IOException{
        int n = in.nextInt();
        int[][] arr = new int[n][n];
        //存入arr中
        for(int i = 0;i < n;i++){
            for(int j = 0;j < n;j++){
                arr[i][j] = in.nextInt();
            }
        }
        //二维前缀和
        int[][] dp = new int[n + 1][n + 1];
        for(int i = 1;i <= n;i++){
            for(int j = 1;j <= n;j++){
                dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + arr[i - 1][j - 1];
            }
        }
        //四层for循环枚举
        int max = Integer.MIN_VALUE;
        for(int x1 = 1;x1 <= n;x1++){
            for(int y1 = 1;y1 <= n;y1++){
                for(int x2 = x1;x2 <= n;x2++){
                    for(int y2 = y1;y2 <= n;y2++){
                        max = Math.max(dp[x2][y2] - dp[x1 - 1][y2] - dp[x2][y1 - 1] + dp[x1 - 1][y1 - 1],max);
                    }
                }
            }
        }
        out.flush();
        out.println(max);
        out.close();

    }
}
class Read{
    StringTokenizer st = new StringTokenizer("");
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

    String next() throws IOException{
        while(!st.hasMoreTokens()){
            st = new StringTokenizer(bf.readLine());
        }
        return st.nextToken();
    }

    int nextInt() throws IOException{
        return Integer.parseInt(next());
    }


}